import java.io.IOException;
import java.util.*;
public class Main
{
    private static void Endline() //结束换行
    {
        System.out.println("\n");
        System.out.println("-------------------------------");
        System.out.println("\n");
    }
    private static void MainMenu() //菜单
    {
        System.out.println("-----欢迎来到学生管理系统-----");
        System.out.println("1.添加");
        System.out.println("2.删除");
        System.out.println("3.查询");
        System.out.println("4.修改");
        System.out.println("0.退出");
        System.out.println("---------------------------");
    }
    private static void Add()
    {
        System.out.println("请输入依次输入数据的学号,姓名,成绩1,成绩2,成绩3:");
        String Info[]=new String[5];
        Scanner in = new Scanner(System.in);
        int i;
        for(i=0;i<5;++i) Info[i]=in.next();
        StudentOperationSystem.Add(Info);
    }
    private static void Delete()
    {
        int cmd=-1;
        System.out.println("请输入操作序号:");
        System.out.println("1.根据学号删除");
        System.out.println("2.根据姓名删除");
        System.out.println("3.删除所有数据");
        System.out.println("0.返回上级");
        Scanner in = new Scanner(System.in);
        cmd = in.nextInt();
        if(cmd==1)
        {
            System.out.println("请输入学号:");
            String info = in.next();
            StudentOperationSystem.DeleteByID(info);
        }
        else if(cmd==2)
        {
            System.out.println("请输入姓名:");
            String info = in.next();
            StudentOperationSystem.DeleteByName(info);
        }
        else if(cmd==3) StudentOperationSystem.DeleteByID("%");
        else if(cmd!=0)
        {
            System.out.println("错误指令!请重新输入!");
            Delete();
        }
    }
    private static void Search()
    {
        int cmd=-1;
        System.out.println("请输入操作序号:");
        System.out.println("1.根据学号搜寻");
        System.out.println("2.根据姓名搜寻");
        System.out.println("3.查询所有学生");
        System.out.println("0.返回上级");
        Scanner in = new Scanner(System.in);
        cmd = in.nextInt();
        if(cmd==1)
        {
            System.out.println("请输入学号:");
            String info = in.next();
            StudentOperationSystem.SearchByID(info);
        }
        else if(cmd==2)
        {
            System.out.println("请输入姓名:");
            String info = in.next();
            StudentOperationSystem.SearchByName(info);
        }
        else if(cmd==3)
        {
            StudentOperationSystem.SearchByID("%");
        }
        else if(cmd!=0)
        {
            System.out.println("错误指令!请重新输入!");
            Search();
        }
    }
    private static void Update()
    {
        int cmd=-1;
        System.out.println("请输入操作序号:");
        System.out.println("1.根据学号更新");
        System.out.println("2.根据姓名更新");
        System.out.println("0.返回上级");
        Scanner in = new Scanner(System.in);
        cmd = in.nextInt();
        if(cmd==1)
        {
            System.out.println("请依次输入查询学号,成绩下标,修改值");
            String info = in.next();
            int index=in.nextInt();
            int value=in.nextInt();
            StudentOperationSystem.AlterByID(info,index,value);
        }
        else if(cmd==2)
        {
            System.out.println("请依次输入查询名字,成绩下标,修改值");
            String info = in.next();
            int index=in.nextInt();
            int value=in.nextInt();
            StudentOperationSystem.AlterByID(info,index,value);
        }
        else if(cmd!=0)
        {
            System.out.println("错误指令!请重新输入!");
            Update();
        }
    }
    private static void Operations(int index)
    {
        if(index==1) Add();
        else if(index==2) Delete();
        else if(index==3) Search();
        else if(index==4) Update();
        else if(index!=0)
        {
            System.out.println("错误指令!请重新输入!");
        }
    }
    public static void main(String[] args) throws IOException //主程序
    {
        int cmd=-1,subcmd;
        while(cmd!=0)
        {
            MainMenu();
            Scanner in = new Scanner(System.in);
            cmd=in.nextInt();
            Operations(cmd);
            Endline();
        }
    }
}